<?php

namespace App\Http\Resources\Menu;

use Illuminate\Http\Resources\Json\Resource;

class AdminMenuResource extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'            =>  $this->id,
            'name'          =>  $this->title,
            'icon'          =>  $this->icon,
            'method'        =>  $this->method,
            'route_name'    =>  $this->route_name,
            'route_match'   =>  $this->route_match,
            'remark'        =>  $this->remark,
            'node'          =>  $this->when('parent_id', $this->id),
        ];
    }
}
